#!/bin/bash

# init delays
s3pic_cntl 0x80 0x04 0x00
s3pic_cntl 0x81 0x04 0x00
s3pic_cntl 0x82 0x04 0x00

# driver on
s3pic_cntl 0x90 0x00 0x80

# PGM asserted
s3pic_cntl 0x90 0x02 0x80

# MCLR deasserted
s3pic_cntl 0x90 0x03 0x80

# init TBLPTR
s3pic_cntl 0x10 0x30 0x0e
s3pic_cntl 0x10 0xf8 0x6e
s3pic_cntl 0x10 0x00 0x0e
s3pic_cntl 0x10 0xf7 0x6e
s3pic_cntl 0x10 0x00 0x0e
s3pic_cntl 0x10 0xf6 0x6e

# read
echo address=0x300000
s3pic_cntl 0x21

# init TBLPTR
s3pic_cntl 0x10 0x3f 0x0e
s3pic_cntl 0x10 0xf8 0x6e
s3pic_cntl 0x10 0xff 0x0e
s3pic_cntl 0x10 0xf7 0x6e
s3pic_cntl 0x10 0xe0 0x0e
s3pic_cntl 0x10 0xf6 0x6e

# read
echo address=0x3fffe0
s3pic_cntl 0x21

# MCLR asserted
s3pic_cntl 0x90 0x02 0x80

# PGM deasserted
s3pic_cntl 0x90 0x00 0x80

# driver off
s3pic_cntl 0x90 0x00 0x00
